package com.example.controller;

import com.example.dto.User;
import com.example.web.HelloService;
import com.example.web.RefactorHelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: xben
 * @Date: 2019/1/28 16:28
 */
@RestController
public class ConsumerController {
    @Autowired
    HelloService helloService;
    @Autowired
    RefactorHelloService refactorHelloService;

    @RequestMapping(value = "/feign-consumer", method = RequestMethod.GET)
    public String helloConsumer() {
        return helloService.hello();
    }

    @RequestMapping(value = "/feign-consumer2", method = RequestMethod.GET)
    public String helloCunsumer2() {
        StringBuilder sb = new StringBuilder();
        sb.append(helloService.hello()).append("\n");
        sb.append(helloService.hello1("DIDI")).append("\n");
        sb.append(helloService.hello2("DIDI", 30)).append("\n");
        sb.append(helloService.hello3(new User("DIDI", 30))).append("\n");
        return sb.toString();
    }

    @RequestMapping(value = "/test", method = RequestMethod.GET)
    public String test() {
        return helloService.testFromClient("鱼小干加袁小萌");
    }

    @RequestMapping(value = "/test1", method = RequestMethod.GET)
    public String test1() {
        return helloService.hello1("DIDI");
    }

    @RequestMapping(value = "/test2", method = RequestMethod.GET)
    public User test2() {
        return helloService.hello2("DIDI", 30);
    }

    @RequestMapping(value = "/test3", method = RequestMethod.GET)
    public String test3() {
        return helloService.hello3(new User("DIDI", 30));
    }

    @RequestMapping(value = "/feign-consumer3", method = RequestMethod.GET)
    public String helloCunsumer3() {
        StringBuilder sb = new StringBuilder();
        sb.append(refactorHelloService.hello("MIMI")).append("\n");
        sb.append(refactorHelloService.hello("MIMI", 30)).append("\n");
        sb.append(refactorHelloService.hello(new com.example.dto.User("MIMI", 30))).append("\n");
        return sb.toString();
    }
}

